Skip to content

futures-channel: ensure is_terminated() reflects the state of the channel#2969

Open
petrosagg wants to merge 2 commits into
rust-lang:mainfrom
petrosagg:termination-detection
Open

futures-channel: ensure is_terminated() reflects the state of the channel#2969
petrosagg wants to merge 2 commits into
rust-lang:mainfrom
petrosagg:termination-detection

Conversation

@petrosagg

Copy link
Copy Markdown
Contributor

I noticed that is_terminated() returns true only after a None value has been observed from the stream. The documentation ofFusedStream allows this method to return true earlier, if the stream can no longer make progress:

Usually, this state occurs after poll_next (or try_poll_next) returned Poll::Ready(None). However, is_terminated may also return true if a stream has become inactive and can no longer make progress and should be ignored or dropped rather than being polled again.

This PR was prompted by a use case that wants to see if the channel has more things to give out without actually pulling them out of the stream since the place of checking is not the right place to handle a potential element from the stream.

This effectively makes .is_terminated() behave like tokio::sync::mpsc::UnboundedReceiver::is_closed().

Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
@rustbot rustbot added A-channel Area: futures::channel S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 16, 2025
@rustbot

rustbot commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (possibly #3022) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-channel Area: futures::channel S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants